import { loc, add_ck_col, reload_col, ck_sn, ck_empty } from 'sui';
import { load_type } from 'manage/station/cmd';

const load_etype = (setType) => load_type(setType, "etype");

const get_fix = () => {
    return [
        {sn: "sn", name: loc("l_405"), tp: "string"},
        {sn: "name", name: loc("l_250"), tp: "string"},
        {sn: "tp", name: loc("l_245"), tp: "string", ctp: "list", ctl: null},
        {sn: "wsn", name: loc("l_100"), tp: "string", ctp: "list", ctl: null, opt: "Y"},
    ];
};

const get_ck = (cur, main, col) => {
    const ret = {
        sn : v => ck_sn(v, cur, main),
        name : v => ck_empty(v),
        tp : v => ck_empty(v),
    };

    add_ck_col(ret, col);

    return ret;
};

const load_col = (setCol) => {
    const fix = get_fix();
    reload_col(null, v => setCol(v), "equip", fix);
};

export {load_etype, load_col, get_ck, get_fix};
